FROM centos:latest

MAINTAINER  xingyu.zhang <681155@qq.com>

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

RUN yum -y update && \
	yum -y install curl gcc openssl-devel pcre-devel zlib-devel make wget

ENV TENGINE_VERSION 2.2.1
ENV TENGINE_NAME tengine-${TENGINE_VERSION}
RUN cd /tmp/ && wget  http://tengine.taobao.org/download/${TENGINE_NAME}.tar.gz &&\
    tar -zxvf ${TENGINE_NAME}.tar.gz -C /tmp/ && chmod -R 777 /tmp/${TENGINE_NAME}



#ADD ./jemalloc-5.0.1.tar.bz2 /tmp/
#RUN cd /tmp/jemalloc-5.0.1 && ./configure --prefix=/usr/local/jemalloc && make && make install

#mkdir
RUN mkdir -p /var/tmp/nginx/client && \
    mkdir -p /var/tmp/nginx/proxy && \
    mkdir -p /var/tmp/nginx/fcgi && \
    mkdir -p /var/tmp/nginx/uwsgi && \
    mkdir -p /var/tmp/nginx/scgi 

#add user
RUN groupadd nginx \
  	&& useradd -r -g nginx nginx


#./configure
RUN cd /tmp/${TENGINE_NAME} && ./configure \
  	--prefix=/usr/local/${TENGINE_NAME} \
 	--error-log-path=/var/log/nginx/error.log \
 	--http-log-path=/var/log/nginx/access.log \
  	--pid-path=/var/run/nginx/nginx.pid  \
  	--lock-path=/var/lock/nginx.lock \
  	--http-client-body-temp-path=/var/tmp/nginx/client \
  	--http-proxy-temp-path=/var/tmp/nginx/proxy \
  	--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
  	--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  	--http-scgi-temp-path=/var/tmp/nginx/scgi \
  	--with-pcre \
  	--user=nginx \
    --group=nginx \
    --with-http_ssl_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_auth_request_module \
    --with-mail \
    --with-mail_ssl_module \
    --with-file-aio \
    --with-ipv6 && \
  	cd /tmp/${TENGINE_NAME} && make && make install && \
  	ln -s /usr/local/${TENGINE_NAME} /usr/local/tengine && \
  	rm -rf /tmp/* && yum clean all

EXPOSE 80
CMD ["/usr/local/tengine/sbin/nginx", "-g", "daemon off;"] 